Home:ALL Converter>Using sklearn's roc_auc_score for OneVsOne Multi-Classification?

Using sklearn's roc_auc_score for OneVsOne Multi-Classification?

Ask Time:2020-02-24T00:57:09         Author:molecularrunner

Json Formatter

So I am working on a model that attempts to use RandomForest to classify samples into 1 of 7 classes. I'm able to build and train the model, but when it comes to evaluating it using roc_auc function, I'm able to perform 'ovr' (oneVsrest) but 'ovo' is giving me some trouble.

roc_auc_score(y_test, rf_probs, multi_class = 'ovr', average = 'weighted')

The above works wonderfully, I get my output, however, when I switch multi_class to 'ovo' which I understand might be better with class imbalances, I get the following error:

roc_auc_score(y_test, rf_probs, multi_class = 'ovo')

IndexError: too many indices for array

(I pasted the whole traceback below!)

Currently my data is set up as follow:

y_test (61,1)

y_probs (61, 7)

Do I need to reshape my data in a special way to use 'ovo'?

In the documentation, https://thomasjpfan.github.io/scikit-learn-website/modules/generated/sklearn.metrics.roc_auc_score.html, it says "binary y_true, y_score is supposed to be the score of the class with greater label. The multiclass case expects shape = [n_samples, n_classes] where the scores correspond to probability estimates."

Additionally, the whole traceback seems to hint as using maybe using a more binary array (hopefully that's the right term! I'm new to this!)

enter image description here

Very, very thankful for any ideas/thoughts!

Author:molecularrunner,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/60364615/using-sklearns-roc-auc-score-for-onevsone-multi-classification
yy